﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Entities.Enums;

namespace Entities
{
    /// <summary>
    /// Question class
    /// </summary>
    public class Question : BaseEntity
    {
        public Question()
            : base(-1)
        {
            this.Type = QuestionType.SingleChoice;
            this.answers = new List<string>();
        }

        public Question(Question src)
            : base(src.ID)
        {
            this.Type = src.Type;
            this.answers = new List<string>(src.answers);
        }

        /// <summary>
        /// Question type
        /// </summary>
        public QuestionType Type { get; set; }

        private string question;
        /// <summary>
        /// Question text
        /// </summary>
        public string QuestionText
        {
            get
            {
                return this.question;
            }
            set
            {
                this.question = value.Trim();
            }
        }

        private List<string> answers;
        /// <summary>
        /// Answers for the question
        /// </summary>
        public List<string> Answers
        {
            get
            {
                return this.answers;
            }
            set
            {
                if (value == null)
                {
                    throw new ArgumentNullException("Answers", "Answers list cannot be null");
                }
                //if (value.Count < 2)
                //{
                //    throw new ArgumentNullException("Answers", "Answers list length cannot be less than 2");
                //}
                this.answers = value;
            }
        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="questionText">Question text</param>
        /// <param name="answers">List of answers</param>
        /// <param name="type">Type of the question</param>
        public Question(string questionText, List<string> answers, QuestionType type = QuestionType.MultipleChoice)
            : base(0)
        {
            this.QuestionText = questionText;
            this.Answers = answers;
            this.Type = type;
        }
    }
}
